﻿var prTdArray =[{name:'名 称 ',id:'pre_name'},{name:'包含药',id:'pre_contain'},{name:'自 拟',id:'pre_constructed'},{name:'结构',id:'pre_chillsAndFever'}];
var prUrl1 = basePath+'/pr/namePrescriptions.jsp'
var prUrl02 = basePath+'/pr/containPrescriptions.jsp';
var prUrl03 = basePath+'/pr/constructedPrescriptions.jsp';
var prUrl04 = basePath+'/pr/chillPrescriptions.jsp';
var centerUrlM = basePath+'/pr/prContentMost.jsp';
var centerUrlO = basePath+'/pr/prContentOne.jsp';

var prescriptionsTab = new Ext.TabPanel({
        renderTo: 'prescriptions_tab',
        activeTab: preActiveTab,
        plain:true,
        defaults:{autoScroll: true,autoHeight: true},
        items:[
            {
                title: prTdArray[0].name,
                id: prTdArray[0].id,
                el:'prescription_name_div',
				autoLoad: {url: prUrl1, params: {preName:searchMess},scripts:true},
				autoScroll: true
            },{
                title: prTdArray[1].name,
                id: prTdArray[1].id,
                el:'prescription_contanin_div',
                autoLoad: {url: prUrl02, params: 'foo=bar&wtf=1',scripts:true},
				 autoScroll: true

            },{
                title: prTdArray[2].name,
                id: prTdArray[2].id,
                el:'prescription_constructed_div',
                autoLoad: {url: prUrl03, params: 'foo=bar&wtf=1',scripts:true},
				 autoScroll: true

            },{
                title: prTdArray[3].name,
                el:'prescription_chill_div',
                id: prTdArray[3].id,
                autoLoad: {url: prUrl04, params: 'foo=bar&wtf=1',scripts:true}
            }
        ]
    });
    
function selectPreRecord(r){
	var size = r.length;
  if(size == 1){
  	comparisonPreOne(centerUrlO,{fjId:r[0].data.id});
  }else{
  	var ids = new Array(); 
  	for(var i=0 ; i < size ; i++ )
  		ids.push(r[i].data.id);
  	comparisonPreMost(centerUrlM,{fjId:ids});
  }

}


function selectPrTab(id){
   var t = prescriptionsTab.getItem(id);
	prescriptionsTab.setActiveTab(t);
	return t;
}

function nameUpda(p){
	 var tab = selectPrTab(prTdArray[0].id);
   	 updataFj(tab,prUrl1,p);
}
function containUpda(p){
	 var tab = selectPrTab(prTdArray[1].id);
   	updataFj(tab,prUrl02,p);
}
function constructedUpda(p){
	 var tab = selectPrTab(prTdArray[2].id);
     updataFj(tab,prUrl03,p);
}
function chillsUpda(p){
	 var tab = selectPrTab(prTdArray[3].id);
	 updataFj(tab,prUrl04,p);
    
}
function updataFj(tabPre,prUrl,p){
 	tabPre.getUpdater().update({
    	url: prUrl,
    	params:p,
    	scripts:true
	});
}